package sum.achilles.com.sum;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.view.Gravity;

import de.greenrobot.event.EventBus;
import sum.achilles.com.Bean.EventBus_Notice;

public class MainActivity extends Activity {

    private DrawerLayout drawerLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        EventBus.getDefault().register(this);
        drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
        drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

    public void onEventMainThread(EventBus_Notice eventBus_notice) {
        if (eventBus_notice.getType() == EventBus_Notice.OPEN_DRAWLAYOUT) {
            drawerLayout.openDrawer(Gravity.RIGHT);
        } else if (eventBus_notice.getType() == EventBus_Notice.CLOSE_DRAWLAYOUT) {
            drawerLayout.closeDrawers();
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
